﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Data.Model;
using Newtonsoft.Json;

namespace MyWeb.Controllers
{
    public class UserController : Controller
    {

        private class mydata {
            public int Id { get; set; }
            public string name { get; set; }
            public string stargazers_count { get; set; }
            public string forks_count { get; set; }
            public string description { get; set; }

            public int Gender { get; set; }
        }

        //
        // GET: /User/

        public ActionResult Index()
        {
            return View();
        }


        private class returndata<T>
        {
            public int total = 0;
            public List<T> rows = new List<T>();
        }
        public string GetUserList() {
            int pagesize = int.Parse(Request.Params["pageSize"]);
            int pageoffset = int.Parse(Request.Params["pageoffset"] ?? "0");
            List<mydata> list = new List<mydata>();
            List<mydata> listresult = new List<mydata>();
            for (int i = 0; i < 300; i++)
            {
                mydata userinfo = new mydata()
                {
                    Gender = 0,
                    Id = i,
                    name = "后台数据name"+i,
                    description = "后台数据简介"+i,
                    forks_count = "后台数据",
                    stargazers_count = "测试"
                };
            list.Add(userinfo);
            }
            listresult = list.Skip(pageoffset).Take(pagesize).ToList();

            returndata<mydata> model = new returndata<mydata>()
            {
                rows = listresult,
                total = 300
            };
            return  JsonConvert.SerializeObject(model);
        }

        

        public ActionResult Edit(int Id) {

            return View();
        }


        public ActionResult Delete(int Id)
        {
            return View();
        
        }

        public ActionResult Add() {
            return View();
        }


    }
}
